Skip to content

Commit b3ba79f

Browse files
committed
Fix tests/pos/i5655
The commits 5cf9e0b incorrectly throw the prefix away and construct the type from the symbol by ignoring type parameters of generic classes. As prefix is already in the "inner normal form", it suffices to select member on it. The commit 22ab968 calls `processInner`, which is effectively an no-op. Also found that we should reset `skiptvs` in reading method parameter and result types.
1 parent 4ae3d64 commit b3ba79f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,10 @@ class ClassfileParser(
349349
val tag = sig(index); index += 1
350350
(tag: @switch) match {
351351
case 'L' =>
352-
/** A type representation where inner classes become `A#B` instead of `A.this.B` (like with `typeRef`) */
352+
/** A type representation where inner classes become `A#B` instead of `A.this.B` (like with `typeRef`)
353+
*
354+
* Note: the symbol must not be nested in a generic class.
355+
*/
353356
def innerType(symbol: Symbol): Type =
354357
if symbol.is(Flags.Package) then
355358
symbol.thisType
@@ -358,7 +361,7 @@ class ClassfileParser(
358361
else
359362
throw new RuntimeException("unexpected term symbol " + symbol)
360363

361-
def processClassType(tp: Type): Type = tp match {
364+
def processTypeArgs(tp: Type): Type = tp match {
362365
case tp: TypeRef =>
363366
if (sig(index) == '<') {
364367
accept('<')
@@ -392,12 +395,12 @@ class ClassfileParser(
392395

393396
val classSym = classNameToSymbol(subName(c => c == ';' || c == '<'))
394397
val classTpe = if (classSym eq defn.ObjectClass) defn.FromJavaObjectType else innerType(classSym)
395-
var tpe = processClassType(classTpe)
398+
var tpe = processTypeArgs(classTpe)
396399
while (sig(index) == '.') {
397400
accept('.')
398401
val name = subName(c => c == ';' || c == '<' || c == '.').toTypeName
399-
val clazz = tpe.member(name).symbol
400-
tpe = processClassType(innerType(clazz))
402+
val tp = tpe.select(name)
403+
tpe = processTypeArgs(tp)
401404
}
402405
accept(';')
403406
tpe
@@ -435,15 +438,15 @@ class ClassfileParser(
435438
paramtypes += {
436439
if isRepeatedParam(index) then
437440
index += 1
438-
val elemType = sig2type(tparams, skiptvs)
441+
val elemType = sig2type(tparams, skiptvs = false)
439442
// `ElimRepeated` is responsible for correctly erasing this.
440443
defn.RepeatedParamType.appliedTo(elemType)
441444
else
442-
sig2type(tparams, skiptvs)
445+
sig2type(tparams, skiptvs = false)
443446
}
444447

445448
index += 1
446-
val restype = sig2type(tparams, skiptvs)
449+
val restype = sig2type(tparams, skiptvs = false)
447450
JavaMethodType(paramnames.toList, paramtypes.toList, restype)
448451
case 'T' =>
449452
val n = subName(';'.==).toTypeName

0 commit comments

Comments
 (0)