Skip to content

Commit 7b3498d

Browse files
committed
Add tests
1 parent 785f107 commit 7b3498d

File tree

5 files changed

+126
-28
lines changed

5 files changed

+126
-28
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Params{
2+
def bar[T](x: T)[T]: String = ??? // error
3+
def zoo(x: Int)[T, U](x: U): T = ??? // error
4+
def bbb[T <: U](x: U)[U]: U = ??? // error // error
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Newline {
2+
def multipleLines
3+
[T]
4+
(x: T)
5+
[U]
6+
(using (T,U))
7+
(y: U)
8+
= ???
9+
}
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11

22
class A{
3-
def f0[T][U](x: Any) = ???
4-
def f0[T][U](x: Int) = ???
3+
/*
4+
def f0[T](x: Any) = ???
5+
def f0[T](x: Int) = ???
6+
*/
57

6-
f0(1)
8+
def f1[T][U](x: Any) = ???
9+
def f1[T][U](x: Int) = ???
10+
11+
//f0(1)
12+
f1(1)
13+
f1("hello")
14+
15+
case class B[U](x: Int)
16+
def b[U](x: Int) = B[U](x)
17+
18+
def f2[T]: [U] => Int => B[U] = [U] => (x: Int) => b[U](x)
19+
20+
21+
f2(1)
22+
f2[Any](1)
23+
f2[Any][Any](1)
724

825
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Params{
2+
type U
3+
def foo[T](x: T)[U >: x.type <: T][L <: List[U]](l: L): L = ???
4+
def aaa(x: U): U = ???
5+
def bbb[T <: U](x: U)[U]: U = ???
6+
}

tests/pos/_typeInterweaving/todo.scala

Lines changed: 86 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,28 @@ def foo[T, U][V](x: T): U = ???
3939

4040
//add function call to chainedParams
4141

42-
43-
// Que faire de TypeDcl ::= id [TypeParamClause] {FunParamClause} TypeBounds [‘=’ Type] //TODO: change to {ParamClauses} ?
44-
45-
46-
/* Endroits à changer: (toujour creation et application)
42+
/* Endroits à changer: (toujour creation et application ?)
4743
function definition Done
4844
function application Already works
49-
class definition In Progress
50-
primary constr In Progress
51-
auxiliary constr In Progress
52-
class instantiation Might already work // see new
53-
given definition Todo
54-
given application(?) Doesn't exist ? or add multiple params to usings ?
55-
type declarations To be determined
45+
class definition Standby
46+
primary constr Standby
47+
auxiliary constr Standby
48+
class instantiation Standby (Might already work // see new)
49+
given definition Todo //yes if given alias, Standby otherwise given name[](using ...)[](using ...) : Classe[Params]
50+
given application(?) Already works ?/standby Doesn't exist ? or add multiple params to usings ? (using name: Class[T]{val x}[U])
51+
type declarations Standby: because no transformation from F[X,Y] <-> F[X][Y] //is [X,Y] =>> F[X][Y] valid ?
5652
type instantiation Doesn't exist ?
57-
extension definition Todo
58-
extension application Todo
53+
extension definition Todo // probably only on right side, since classes do not keep info about params
54+
extension application Todo: tester
5955
*/
6056

6157

6258

6359
// étapes pour "convaincre"
64-
// 1) exemples simples, et exemples d'utilité
65-
// 2) expliquer intuitivement
66-
// 3) update la doc
67-
// 4) PR et tout le tralala
60+
// 1) exemples simples, et exemples d'utilité TODO
61+
// 2) expliquer intuitivement TODO
62+
// 3) update la doc Done
63+
// 4) PR et tout le tralala TODO
6864

6965

7066
//potentiellement cette feature en experimental
@@ -77,20 +73,85 @@ val f = foo //should work and doesn't preserve type params yet
7773

7874

7975
//new:
80-
// mettre de coté la partie sur les classes
81-
// fork le repo de la doc est faire changements appropriés
76+
// mettre de coté la partie sur les classes: Done
77+
// fork le repo de la doc est faire changements appropriés: Done: https://github.com/scala/scala/pull/9792
8278
// check overloading resolution
83-
// Applications.scala resolveMapped
79+
// Applications.scala resolveMapped //What to do here?
8480
// methType
8581
// ProtoTypes.scala
8682

87-
// check ne passer aucun arguments à une fonction
88-
// voir fichier overload dans pos/interweaving_
89-
// voir methType
83+
// check ne passer aucun arguments à une fonction // Je me rappelle pas ce que c'était ...
84+
// voir fichier overload dans pos/interweaving_ // Done
85+
// voir methType // Done ?
9086
// check occurances de PolyType et PolyProto pour être sûr que ça fonctionne bien avec les [T][U]
87+
// PolyType: Done in Application.scala
88+
// PolyProto: Done in Application.scala
9189
// testCompilation
90+
// Pas eu le temps, mais la PR a lancer des tests, donc 5 qui ont ratés dans une phase
9291

92+
// check def foo[T][T]
93+
//
94+
// is def foo[T](using T)(x: Int) valid ?
95+
/*
96+
* check: done see newline.scala
97+
* def foo
98+
* [T]
99+
* (x: T)
100+
* [U]
101+
*
102+
* and similar
103+
*
104+
*/
93105

94106

95107
// should we allow fun[L <: List[T]][T] as alias for something like fun[F[_] <: List[]][T][L <: F[T]]
96-
// I'm not sure it's useful
108+
// I'm not sure it's useful
109+
110+
111+
112+
// dans docu check "method type" et "poly(morphic) type/method" pour voir si suppositions fausses
113+
//
114+
115+
// tryApply:
116+
// si f pas fonction, essaie f.apply(...)
117+
118+
119+
120+
// next:
121+
// Relire toute docu: Done
122+
// voir eta expension dans la doc, pour voir comment changer pour polymorphique, ajouter texte qui explique que passe parfois param de type si besoin
123+
// mettre un peu au propre texte PR -> trouver exemples
124+
// essayer given def: Paused
125+
126+
127+
/**
128+
* A few comments:
129+
Should handle and test for extension definitions as well.
130+
Should test of overriding and signature check and proper report when signature does not match.
131+
I suggest opening a thread on https://contributors.scala-lang.org/ to discuss this language change.
132+
*
133+
*
134+
*
135+
*
136+
*/
137+
138+
139+
// type Z = X =>> F[X]
140+
// def name: [X] => (X, X) => (U)
141+
142+
143+
// def foo[T](x: T): T
144+
// val bar = foo
145+
146+
147+
// check overload: (should fail)
148+
// def foo(x: Int)(y: String)
149+
// def foo(x: Int)[T](y: String)
150+
// def foo[T](x: Int)(y: String)
151+
152+
153+
154+
// next
155+
// adaptations faitent dans Typer.scala adapt (regarder la fin ou il y a le "vrai" body de la fonction)
156+
// pour rajouter le cas valId3 qui typecheck (les autres cas ce sera pour après)
157+
// https://github.com/lampepfl/dotty/pull/4672

0 commit comments

Comments
 (0)