mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:09:48 +00:00
Fix for type inference from instance creation arguments.
R=brianwilkerson@google.com, paulberry@google.com Change-Id: I0e8386f2a7b3e6d034350a21e474fc1a297c0120 Reviewed-on: https://dart-review.googlesource.com/48762 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
055dfad887
commit
3306aabd82
|
@ -5233,7 +5233,11 @@ class _UnitResynthesizer extends UnitResynthesizer with UnitResynthesizerMixin {
|
|||
DartType buildTypeForClassInfo(
|
||||
info, int numTypeArguments, DartType Function(int i) getTypeArgument) {
|
||||
ClassElementForLink class_ = info.element;
|
||||
if (numTypeArguments == 0) return class_.typeWithDefaultBounds;
|
||||
if (numTypeArguments == 0) {
|
||||
DartType type = class_.typeWithDefaultBounds;
|
||||
_typesWithImplicitArguments[type] = true;
|
||||
return type;
|
||||
}
|
||||
return class_.buildType(getTypeArgument, const []);
|
||||
}
|
||||
|
||||
|
|
|
@ -6660,6 +6660,43 @@ D<T> f<T>() {}
|
|||
}
|
||||
}
|
||||
|
||||
test_infer_instanceCreation_fromArguments() async {
|
||||
var library = await checkLibrary('''
|
||||
class A {}
|
||||
|
||||
class B extends A {}
|
||||
|
||||
class S<T extends A> {
|
||||
S(T _);
|
||||
}
|
||||
|
||||
var s = new S(new B());
|
||||
''');
|
||||
if (isStrongMode) {
|
||||
checkElementText(library, '''
|
||||
class A {
|
||||
}
|
||||
class B extends A {
|
||||
}
|
||||
class S<T extends A> {
|
||||
S(T _);
|
||||
}
|
||||
S<B> s;
|
||||
''');
|
||||
} else {
|
||||
checkElementText(library, '''
|
||||
class A {
|
||||
}
|
||||
class B extends A {
|
||||
}
|
||||
class S<T extends A> {
|
||||
S(T _);
|
||||
}
|
||||
dynamic s;
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
||||
test_infer_property_set() async {
|
||||
var library = await checkLibrary('''
|
||||
class A {
|
||||
|
|
Loading…
Reference in a new issue