Skip to content

Commit 4238c51

Browse files
committed
Fix isAbsType prediction in TreeUnpickler
TreeUnpickler assumed that a type was an abstract type if its RHS was a TypeBounds tree. But TypeBounds trees also encode alias types, so this needs to be refined. Fixes #14858
1 parent 8c404b1 commit 4238c51

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4206,7 +4206,7 @@ object Types {
42064206
* This is the case if tycon is higher-kinded. This means
42074207
* it is a subtype of a hk-lambda, but not a match alias.
42084208
* (normal parameterized aliases are removed in `appliedTo`).
4209-
* Applications of hgher-kinded type constructors to wildcard arguments
4209+
* Applications of higher-kinded type constructors to wildcard arguments
42104210
* are equivalent to existential types, which are not supported.
42114211
*/
42124212
def isUnreducibleWild(using Context): Boolean =

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,13 @@ class TreeUnpickler(reader: TastyReader,
507507
rdr.reader.readNat() // length
508508
rdr.skipParams() // tparams
509509
rdr.isAbstractType(rdr.nextUnsharedTag)
510-
case TYPEBOUNDS | TYPEBOUNDStpt => true
510+
case TYPEBOUNDS =>
511+
val rdr = fork
512+
rdr.reader.readByte() // tag
513+
val end = rdr.reader.readEnd()
514+
rdr.skipTree() // alias, or lower bound
515+
!rdr.nothingButMods(end)
516+
case TYPEBOUNDStpt => true
511517
case _ => false
512518
}
513519

@@ -562,7 +568,7 @@ class TreeUnpickler(reader: TastyReader,
562568
val rhsIsEmpty = nothingButMods(end)
563569
if (!rhsIsEmpty) skipTree()
564570
val (givenFlags, annotFns, privateWithin) = readModifiers(end)
565-
pickling.println(i"creating symbol $name at $start with flags $givenFlags")
571+
pickling.println(i"creating symbol $name at $start with flags ${givenFlags.flagsString}, isAbsType = $isAbsType, $ttag")
566572
val flags = normalizeFlags(tag, givenFlags, name, isAbsType, rhsIsEmpty)
567573
def adjustIfModule(completer: LazyType) =
568574
if (flags.is(Module)) adjustModuleCompleter(completer, name) else completer

tests/pos/i14858/A_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import p.*
2+
3+
type NAME2 = C[?]

tests/pos/i14858/M_1.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package p
2+
3+
object M {
4+
class C[N]()
5+
}
6+
7+
export M.*
8+
9+
type CC[N] = M.C[N]
10+
type CCC = M.C[Int]

0 commit comments

Comments
 (0)