Skip to content

Add warnings where new modifier is used. #28

@twiglet

Description

@twiglet

A final comment for today (I was curious how you solved this C# feature):
Given the following C# file:

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace ch.fhnw.imvs
{
class B {
public virtual void foo() {
Console.WriteLine("B:foo");
}
}
class D : B {
public new void foo() {
Console.WriteLine("D:foo");
}
}

public class Test5 {
public static void Main(){
B b = new D();
b.foo();
Console.WriteLine("Done");
}
}
/*
Output:
B:foo
*/
}

Executing this program generates the output B:foo. If I run the generated Java program (the generated code is attached), then the output is D:foo. Has to do with the "new" modifier I used in class D.

I do not yet know how that problem could be solved in Java.

Yes, we naively assume all methods are virtual as in Java. I will
have a think about how we can improve this. And, in the meantime I
will add warnings where the new modifier is used.

Thanks again for your feedback.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions