File tree 6 files changed +18
-9
lines changed
compiler/src/dotty/tools/dotc
docs/docs/reference/changed-features
6 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -851,6 +851,9 @@ object Types {
851
851
ctx.typeComparer.isSameType(this , that)
852
852
}
853
853
854
+ final def frozen_=:= (that : Type )(implicit ctx : Context ): Boolean =
855
+ ctx.typeComparer.isSameTypeWhenFrozen(this , that)
856
+
854
857
/** Is this type a primitive value type which can be widened to the primitive value type `that`? */
855
858
def isValueSubType (that : Type )(implicit ctx : Context ): Boolean = widen match {
856
859
case self : TypeRef if self.symbol.isPrimitiveValueClass =>
Original file line number Diff line number Diff line change @@ -67,8 +67,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
67
67
else tp
68
68
69
69
private def sameBound (lo : Type , hi : Type ): Boolean =
70
- try ctx.typeComparer.isSameTypeWhenFrozen(lo, hi)
71
- catch { case NonFatal (ex) => false }
70
+ try lo frozen_=:= hi catch { case NonFatal (ex) => false }
72
71
73
72
private def homogenizeArg (tp : Type ) = tp match {
74
73
case TypeBounds (lo, hi) if homogenizedView && sameBound(lo, hi) => homogenize(hi)
Original file line number Diff line number Diff line change @@ -1396,11 +1396,14 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1396
1396
val strippedType2 = stripImplicit(fullType2, + 1 )
1397
1397
1398
1398
val result = compareWithTypes(strippedType1, strippedType2)
1399
- if (result != 0 ) result
1400
- else if (implicitBalance != 0 ) - implicitBalance.signum
1399
+ if (result != 0 || ! ctx.typerState.test(implicit ctx => strippedType1 =:= strippedType2))
1400
+ result
1401
+ else if (implicitBalance != 0 )
1402
+ - implicitBalance.signum
1401
1403
else if ((strippedType1 `ne` fullType1) || (strippedType2 `ne` fullType2))
1402
1404
compareWithTypes(fullType1, fullType2)
1403
- else 0
1405
+ else
1406
+ 0
1404
1407
}}
1405
1408
1406
1409
def narrowMostSpecific (alts : List [TermRef ])(implicit ctx : Context ): List [TermRef ] = track(" narrowMostSpecific" ) {
@@ -1663,7 +1666,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1663
1666
// ps(i) = List(p_i_1, ..., p_i_n) -- i.e. a column
1664
1667
// If all p_i_k's are the same, assume the type as formal parameter
1665
1668
// type of the i'th parameter of the closure.
1666
- if (isUniform(ps)(ctx.typeComparer.isSameTypeWhenFrozen(_, _) )) ps.head
1669
+ if (isUniform(ps)(_ frozen_ =:= _ )) ps.head
1667
1670
else WildcardType )
1668
1671
def isPartial = // we should generate a partial function for the arg
1669
1672
fn.get.isInstanceOf [untpd.Match ] &&
Original file line number Diff line number Diff line change @@ -114,8 +114,10 @@ affect implicits on the language level.
114
114
An alternative A is _ more specific_ than an alternative B if
115
115
116
116
- the relative weight of A over B is greater than the relative weight of B over A, or
117
- - the relative weights are the same and A takes more inferable parameters than B, or
118
- - the relative weights and the number of inferable parameters are the same and
117
+ - the relative weights are the same, and the returned types of A and B are
118
+ unifiable, and A takes more inferable parameters than B, or
119
+ - the relative weights and the number of inferable parameters are the same, and
120
+ the returned types of A and B are unifiable, and
119
121
A is more specific than B if all inferable parameters in either alternative are
120
122
replaced by regular parameters.
121
123
Original file line number Diff line number Diff line change
1
+ <44..44> in i3430.scala
2
+ ambiguous implicit arguments: both object Long in object Ordering and object Short in object Ordering match type Ordering[B] of parameter cmp of method min in trait TraversableOnce
Original file line number Diff line number Diff line change 1
1
object Test extends App {
2
2
3
- println(Nil .min) // error: no implicit found
3
+ println(Nil .min) // error: ambiguous
4
4
5
5
}
You can’t perform that action at this time.
0 commit comments