From 22ab968fd04ffcd62323c0d410696c484e9a1a12 Mon Sep 17 00:00:00 2001 From: Vlastimil Dort Date: Fri, 21 Dec 2018 16:43:20 -0500 Subject: [PATCH] Fix #5655: Use a prefix to construct a TypeRef 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. --- .../tools/dotc/core/classfile/ClassfileParser.scala | 2 +- tests/pos/i5655/J_1.java | 11 +++++++++++ tests/pos/i5655/S_2.scala | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i5655/J_1.java create mode 100644 tests/pos/i5655/S_2.scala diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 9af3319c85e5..80377807dedc 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -363,7 +363,7 @@ class ClassfileParser( accept('.') val name = subName(c => c == ';' || c == '<' || c == '.').toTypeName val clazz = tpe.member(name).symbol - tpe = processClassType(processInner(clazz.typeRef)) + tpe = processClassType(processInner(TypeRef(tpe, clazz))) } accept(';') tpe diff --git a/tests/pos/i5655/J_1.java b/tests/pos/i5655/J_1.java new file mode 100644 index 000000000000..815bfaa2cd26 --- /dev/null +++ b/tests/pos/i5655/J_1.java @@ -0,0 +1,11 @@ +public class J_1{ + public class A{ + public class B{} + } + A.B m(){ + J_1 j = new J_1(); + A a = j.new A<>(); + A.B b = a.new B<>(); + return b; + } +} \ No newline at end of file diff --git a/tests/pos/i5655/S_2.scala b/tests/pos/i5655/S_2.scala new file mode 100644 index 000000000000..9e85d0183911 --- /dev/null +++ b/tests/pos/i5655/S_2.scala @@ -0,0 +1,6 @@ +object O { + def main(args: Array[String]) = { + val j = new J_1 + val ab: J_1#A[String]#B[String] = j.m() + } +} \ No newline at end of file