Skip to content

Commit 10d868c

Browse files
committed
More tests
and a typo fixed
1 parent 4c6a69e commit 10d868c

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
13121312
case tp1: RefinedType =>
13131313
tp2 match {
13141314
case tp2: RefinedType if tp1.refinedName == tp2.refinedName =>
1315-
// Given two refinements `T1 { X = S1 }` and `T2 { X = S2 }` rwrite to
1315+
// Given two refinements `T1 { X = S1 }` and `T2 { X = S2 }` rewrite to
13161316
// `T1 & T2 { X B }` where `B` is the conjunction of the bounds of `X` in `T1` and `T2`.
13171317
//
13181318
// However, if `homogenizeArgs` is set, and both aliases `X = Si` are

tests/pos/t5070.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,26 @@ class Test {
1313

1414
implicitly[a.T](b(a)) // works
1515
}
16+
17+
18+
class ImplicitVsTypeAliasTezt {
19+
20+
class Monad[m[_]] {
21+
type For[a] = _For[m, a]
22+
implicit def toFor[a](m: m[a]): For[a] = throw new Error("todo") // lookup fails
23+
// implicit def toFor[a](m: m[a]): _For[m, a] = throw new Error("todo") // fine.
24+
}
25+
26+
trait _For[m[_], a] {
27+
def map[b](p: a => b): m[b]
28+
}
29+
30+
def useMonad[m[_], a](m: m[a])(implicit i: Monad[m]) = {
31+
import i._
32+
33+
// value map is not a member of type parameter m[a]
34+
for {
35+
x <- m
36+
} yield x.toString
37+
}
38+
}

tests/pos/t5643.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
object TupledEvidenceTest {
2+
3+
abstract class TupledEvidence[M[_], T0] { type T = T0 }
4+
5+
implicit def witnessTuple2[M[_], T1, T2](implicit ev1: M[T1], ev2: M[T2]):
6+
TupledEvidence[M, (T1, T2)] { type T = (T1, T2) } = sys.error("")
7+
8+
class GetResult[T]
9+
10+
implicit val getString: GetResult[String] = new GetResult[String]
11+
12+
implicit def getTuple[T](implicit w: TupledEvidence[GetResult, T]): GetResult[w.T] = sys.error("")
13+
14+
def f[T : GetResult] = ""
15+
16+
f[(String,String)](getTuple[(String, String)])
17+
18+
f[(String,String)]
19+
}

0 commit comments

Comments
 (0)