Skip to content

Commit e6592d9

Browse files
Backport "Fix isAliasType" to LTS (#21081)
Backports #20195 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 98ea9d7 + af95a38 commit e6592d9

File tree

13 files changed

+23
-14
lines changed

13 files changed

+23
-14
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureOps.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ extension (tp: Type)
107107
case tp @ CapturingType(parent, refs) =>
108108
val pcs = getBoxed(parent)
109109
if tp.isBoxed then refs ++ pcs else pcs
110-
case tp: TypeRef if tp.symbol.isAbstractType => CaptureSet.empty
110+
case tp: TypeRef if tp.symbol.isAbstractOrParamType => CaptureSet.empty
111111
case tp: TypeProxy => getBoxed(tp.superType)
112112
case tp: AndType => getBoxed(tp.tp1) ** getBoxed(tp.tp2)
113113
case tp: OrType => getBoxed(tp.tp1) ++ getBoxed(tp.tp2)

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -684,11 +684,9 @@ object SymDenotations {
684684
def isWrappedToplevelDef(using Context): Boolean =
685685
!isConstructor && owner.isPackageObject
686686

687-
/** Is this symbol an abstract type? */
688-
final def isAbstractType(using Context): Boolean = this.is(DeferredType)
689-
690687
/** Is this symbol an alias type? */
691-
final def isAliasType(using Context): Boolean = isAbstractOrAliasType && !this.is(Deferred)
688+
final def isAliasType(using Context): Boolean =
689+
isAbstractOrAliasType && !isAbstractOrParamType
692690

693691
/** Is this symbol an abstract or alias type? */
694692
final def isAbstractOrAliasType: Boolean = isType & !isClass

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ object TypeErasure {
266266
tp.paramNames, tp.paramNames map (Function.const(TypeBounds.upper(defn.ObjectType))), tp.resultType)
267267

268268
if (defn.isPolymorphicAfterErasure(sym)) eraseParamBounds(sym.info.asInstanceOf[PolyType])
269-
else if (sym.isAbstractType) TypeAlias(WildcardType)
269+
else if (sym.isAbstractOrParamType) TypeAlias(WildcardType)
270270
else if sym.is(ConstructorProxy) then NoType
271271
else if (sym.isConstructor) outer.addParam(sym.owner.asClass, erase(tp)(using preErasureCtx))
272272
else if (sym.is(Label)) erase.eraseResult(sym.info)(using preErasureCtx)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2571,7 +2571,7 @@ object Types extends TypeUtils {
25712571
symd.maybeOwner.membersNeedAsSeenFrom(prefix) && !symd.is(NonMember)
25722572
|| prefix.match
25732573
case prefix: Types.ThisType =>
2574-
(symd.isAbstractType
2574+
(symd.isAbstractOrParamType
25752575
|| symd.isTerm
25762576
&& !symd.flagsUNSAFE.isOneOf(Module | Final | Param)
25772577
&& !symd.isConstructor

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
445445
if (sym.isAliasType)
446446
api.TypeAlias.of(name, access, modifiers, as.toArray, typeParams, apiType(tpe.bounds.hi))
447447
else {
448-
assert(sym.isAbstractType)
448+
assert(sym.isAbstractOrParamType)
449449
api.TypeDeclaration.of(name, access, modifiers, as.toArray, typeParams, apiType(tpe.bounds.lo), apiType(tpe.bounds.hi))
450450
}
451451
}

compiler/src/dotty/tools/dotc/typer/Deriving.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ trait Deriving {
3131
/** A version of Type#underlyingClassRef that works also for higher-kinded types */
3232
private def underlyingClassRef(tp: Type): Type = tp match {
3333
case tp: TypeRef if tp.symbol.isClass => tp
34-
case tp: TypeRef if tp.symbol.isAbstractType => NoType
34+
case tp: TypeRef if tp.symbol.isAbstractOrParamType => NoType
3535
case tp: TermRef => NoType
3636
case tp: TypeProxy => underlyingClassRef(tp.superType)
3737
case _ => NoType

compiler/src/dotty/tools/dotc/typer/Implicits.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ trait ImplicitRunInfo:
596596
private def isAnchor(sym: Symbol) =
597597
sym.isClass && !isExcluded(sym)
598598
|| sym.isOpaqueAlias
599-
|| sym.is(Deferred, butNot = Param)
599+
|| sym.is(Deferred)
600600
|| sym.info.isInstanceOf[MatchAlias]
601601

602602
private def computeIScope(rootTp: Type): OfTypeImplicits =

compiler/src/dotty/tools/dotc/typer/Namer.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class Namer { typer: Typer =>
271271
analyzeRHS(body)
272272
case _ =>
273273
if rhs.isEmpty || flags.is(Opaque) then flags |= Deferred
274-
analyzeRHS(tree.rhs)
274+
if flags.is(Param) then tree.rhs else analyzeRHS(tree.rhs)
275275

276276
// to complete a constructor, move one context further out -- this
277277
// is the context enclosing the class. Note that the context in which a

compiler/src/dotty/tools/dotc/typer/Synthesizer.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
657657

658658
def canManifest(tp: Manifestable, topLevel: Boolean) =
659659
val sym = tp.typeSymbol
660-
!sym.isAbstractType
660+
!sym.isAbstractOrParamType
661661
&& hasStableErasure(tp)
662662
&& !(topLevel && defn.isBottomClassAfterErasure(sym))
663663

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2649,7 +2649,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
26492649
def isAliasType: Boolean = self.denot.isAliasType
26502650
def isAnonymousClass: Boolean = self.denot.isAnonymousClass
26512651
def isAnonymousFunction: Boolean = self.denot.isAnonymousFunction
2652-
def isAbstractType: Boolean = self.denot.isAbstractType
2652+
def isAbstractType: Boolean = self.denot.isAbstractOrParamType
26532653
def isClassConstructor: Boolean = self.denot.isClassConstructor
26542654
def isType: Boolean = self.isType
26552655
def isTerm: Boolean = self.isTerm

library/src/scala/quoted/Quotes.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3993,7 +3993,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
39933993
/** Is this symbol an anonymous function? */
39943994
def isAnonymousFunction: Boolean
39953995

3996-
/** Is this symbol an abstract type? */
3996+
/** Is this symbol an abstract type or a type parameter? */
39973997
def isAbstractType: Boolean
39983998

39993999
/** Is this the constructor of a class? */

tests/neg/i20079/Lib_1.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Foo:
2+
def xyz[A, CC[X] <: Iterable[X]](coll: CC[A]): Unit = ()
3+
4+
object Bar:
5+
export Foo.xyz

tests/neg/i20079/Test_2.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test:
2+
val ints = List(1)
3+
Foo.xyz[Int, List](ints)
4+
Foo.xyz[Int, scala.collection.View](ints) // error
5+
Bar.xyz[Int, List](ints)
6+
Bar.xyz[Int, scala.collection.View](ints) // error

0 commit comments

Comments
 (0)