Skip to content

Commit b3a3738

Browse files
Revert "Drop phase.isTyper use in isLegalPrefix/asf" from Scala 3.6.4 (#22653)
2 parents bc3e415 + e25316c commit b3a3738

File tree

14 files changed

+25
-241
lines changed

14 files changed

+25
-241
lines changed

Diff for: compiler/src/dotty/tools/dotc/core/TypeComparer.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
369369
}
370370
compareWild
371371
case tp2: LazyRef =>
372-
isBottom(tp1)
373-
|| !tp2.evaluating && recur(tp1, tp2.ref)
372+
isBottom(tp1) || !tp2.evaluating && recur(tp1, tp2.ref)
374373
case CapturingType(_, _) =>
375374
secondTry
376375
case tp2: AnnotatedType if !tp2.isRefining =>
@@ -490,7 +489,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
490489
// If `tp1` is in train of being evaluated, don't force it
491490
// because that would cause an assertionError. Return false instead.
492491
// See i859.scala for an example where we hit this case.
493-
tp2.isAny
492+
tp2.isRef(AnyClass, skipRefined = false)
494493
|| !tp1.evaluating && recur(tp1.ref, tp2)
495494
case AndType(tp11, tp12) =>
496495
if tp11.stripTypeVar eq tp12.stripTypeVar then recur(tp11, tp2)

Diff for: compiler/src/dotty/tools/dotc/core/TypeOps.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ object TypeOps:
124124
}
125125

126126
def isLegalPrefix(pre: Type)(using Context): Boolean =
127-
pre.isStable
127+
pre.isStable || !ctx.phase.isTyper
128128

129129
/** Implementation of Types#simplified */
130130
def simplify(tp: Type, theMap: SimplifyMap | Null)(using Context): Type = {

Diff for: compiler/src/dotty/tools/dotc/core/Types.scala

+16-13
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ object Types extends TypeUtils {
9898
// ----- Tests -----------------------------------------------------
9999

100100
// // debug only: a unique identifier for a type
101-
// val uniqId = { nextId = nextId + 1; nextId }
102-
// if uniqId == 19555 then trace.dumpStack()
101+
// val uniqId = {
102+
// nextId = nextId + 1
103+
// if (nextId == 19555)
104+
// println("foo")
105+
// nextId
106+
// }
103107

104108
/** A cache indicating whether the type was still provisional, last time we checked */
105109
@sharable private var mightBeProvisional = true
@@ -5578,25 +5582,24 @@ object Types extends TypeUtils {
55785582
}
55795583

55805584
def & (that: TypeBounds)(using Context): TypeBounds =
5581-
val lo1 = this.lo.stripLazyRef
5582-
val lo2 = that.lo.stripLazyRef
5583-
val hi1 = this.hi.stripLazyRef
5584-
val hi2 = that.hi.stripLazyRef
5585-
55865585
// This will try to preserve the FromJavaObjects type in upper bounds.
55875586
// For example, (? <: FromJavaObjects | Null) & (? <: Any),
55885587
// we want to get (? <: FromJavaObjects | Null) intead of (? <: Any),
55895588
// because we may check the result <:< (? <: Object | Null) later.
5590-
if hi1.containsFromJavaObject && (hi1 frozen_<:< hi2) && (lo2 frozen_<:< lo1) then
5589+
if this.hi.containsFromJavaObject
5590+
&& (this.hi frozen_<:< that.hi)
5591+
&& (that.lo frozen_<:< this.lo) then
55915592
// FromJavaObject in tp1.hi guarantees tp2.hi <:< tp1.hi
55925593
// prefer tp1 if FromJavaObject is in its hi
55935594
this
5594-
else if hi2.containsFromJavaObject && (hi2 frozen_<:< hi1) && (lo1 frozen_<:< lo2) then
5595+
else if that.hi.containsFromJavaObject
5596+
&& (that.hi frozen_<:< this.hi)
5597+
&& (this.lo frozen_<:< that.lo) then
55955598
// Similarly, prefer tp2 if FromJavaObject is in its hi
55965599
that
5597-
else if (lo1 frozen_<:< lo2) && (hi2 frozen_<:< hi1) then that
5598-
else if (lo2 frozen_<:< lo1) && (hi1 frozen_<:< hi2) then this
5599-
else TypeBounds(lo1 | lo2, hi1 & hi2)
5600+
else if (this.lo frozen_<:< that.lo) && (that.hi frozen_<:< this.hi) then that
5601+
else if (that.lo frozen_<:< this.lo) && (this.hi frozen_<:< that.hi) then this
5602+
else TypeBounds(this.lo | that.lo, this.hi & that.hi)
56005603

56015604
def | (that: TypeBounds)(using Context): TypeBounds =
56025605
if ((this.lo frozen_<:< that.lo) && (that.hi frozen_<:< this.hi)) this
@@ -5605,7 +5608,7 @@ object Types extends TypeUtils {
56055608

56065609
override def & (that: Type)(using Context): Type = that match {
56075610
case that: TypeBounds => this & that
5608-
case _ => super.&(that)
5611+
case _ => super.& (that)
56095612
}
56105613

56115614
override def | (that: Type)(using Context): Type = that match {

Diff for: compiler/src/dotty/tools/dotc/transform/Recheck.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ abstract class Recheck extends Phase, SymTransformer:
219219
sharpen: Denotation => Denotation)(using Context): Type =
220220
if name.is(OuterSelectName) then tree.tpe
221221
else
222-
val pre = ta.maybeSkolemizePrefix(qualType, name)
222+
//val pre = ta.maybeSkolemizePrefix(qualType, name)
223223
val mbr =
224224
sharpen(
225-
qualType.findMember(name, pre,
225+
qualType.findMember(name, qualType,
226226
excluded = if tree.symbol.is(Private) then EmptyFlags else Private
227227
)).suchThat(tree.symbol == _)
228228
val newType = tree.tpe match

Diff for: compiler/test/dotc/pos-test-pickling.blacklist

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ t5031_2.scala
2424
i16997.scala
2525
i7414.scala
2626
i17588.scala
27-
i8300.scala
2827
i9804.scala
2928
i13433.scala
3029
i16649-irrefutable.scala

Diff for: tests/neg-custom-args/captures/lazylist.check

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist.scala:41:42 -------------------------------------
3030
41 | val ref4c: LazyList[Int]^{cap1, ref3} = ref4 // error
3131
| ^^^^
32-
| Found: (ref4 : lazylists.LazyList[Int]^{cap3, ref1, ref2})
32+
| Found: (ref4 : lazylists.LazyList[Int]^{cap3, cap2, ref1, cap1})
3333
| Required: lazylists.LazyList[Int]^{cap1, ref3}
3434
|
3535
| longer explanation available when compiling with `-explain`

Diff for: tests/neg/6314-6.check

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
|object creation impossible, since def apply(fa: String): Int in trait XX in object Test3 is not defined
55
|(Note that
66
| parameter String in def apply(fa: String): Int in trait XX in object Test3 does not match
7-
| parameter Test3.Bar[X & (X & Y)] in def apply(fa: Test3.Bar[X & YY.this.Foo]): Test3.Bar[Y & YY.this.Foo] in trait YY in object Test3
7+
| parameter Test3.Bar[X & Object with Test3.YY {...}#Foo] in def apply(fa: Test3.Bar[X & YY.this.Foo]): Test3.Bar[Y & YY.this.Foo] in trait YY in object Test3
88
| )
99
-- Error: tests/neg/6314-6.scala:52:3 ----------------------------------------------------------------------------------
1010
52 | (new YY {}).boom // error: object creation impossible
1111
| ^
1212
|object creation impossible, since def apply(fa: String): Int in trait XX in object Test4 is not defined
1313
|(Note that
1414
| parameter String in def apply(fa: String): Int in trait XX in object Test4 does not match
15-
| parameter Test4.Bar[X & (X & Y)] in def apply(fa: Test4.Bar[X & YY.this.FooAlias]): Test4.Bar[Y & YY.this.FooAlias] in trait YY in object Test4
15+
| parameter Test4.Bar[X & Object with Test4.YY {...}#FooAlias] in def apply(fa: Test4.Bar[X & YY.this.FooAlias]): Test4.Bar[Y & YY.this.FooAlias] in trait YY in object Test4
1616
| )

Diff for: tests/neg/i6225.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
object O1 { // error: cannot be instantiated
1+
object O1 {
22
type A[X] = X
33
opaque type T = A // error: opaque type alias must be fully applied
44
}

Diff for: tests/pos/i17222.2.scala

-30
This file was deleted.

Diff for: tests/pos/i17222.3.scala

-39
This file was deleted.

Diff for: tests/pos/i17222.4.scala

-71
This file was deleted.

Diff for: tests/pos/i17222.5.scala

-26
This file was deleted.

Diff for: tests/pos/i17222.8.scala

-18
This file was deleted.

Diff for: tests/pos/i17222.scala

-33
This file was deleted.

0 commit comments

Comments
 (0)