Skip to content

Wrong prefix of java inner class parsed from java signature #5655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
panacekcz opened this issue Dec 21, 2018 · 0 comments
Closed

Wrong prefix of java inner class parsed from java signature #5655

panacekcz opened this issue Dec 21, 2018 · 0 comments

Comments

@panacekcz
Copy link
Contributor

A method in the following Java code returns an inner class of a generic class. In scalac, the type is J_1#A[String]#B[String], in dotty it is j.A[T]#B[String]:

  • the type argument of A is lost,
  • the prefix depends on the receiver of the method.

J_1.java:

public class J_1{
    public class A<T>{
        public class B<U>{}
    }
    A<String>.B<String> m(){
        J_1 j = new J_1();
        A<String> a = j.new A<>();
        A<String>.B<String> b = a.new B<>();
        return b;
    }
}

S_2.scala:

object O{
  def main(args: Array[String]) = {
    val j = new J_1
    val ab: J_1#A[String]#B[String] = j.m()
  }
}

Output:

-- [E007] Type Mismatch Error: S_2.scala:4:41 --------------
4 |    val ab: J_1#A[String]#B[String] = j.m()
  |                                      ^^^^^
  |                                      Found:    j.A[T]#B[String]
  |                                      Required: J_1#A[String]#B[String]

There seems to be a simple fix so I intend to post a PR.

odersky added a commit that referenced this issue Dec 30, 2018
Fix #5655: Use a prefix to construct a TypeRef when parsing Java signature
nicolasstucki pushed a commit to dotty-staging/dotty that referenced this issue Jan 5, 2019
Fixes the prefix of inner classes when parsing Java signatures.
Uses the prefix computed from the signature instead of just the symbol
to construct the TypeRef.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant