Skip to content

dart_bin checked-mode: generics extension error #718

Closed
@DartBot

Description

@DartBot

This issue was originally filed by karl.kruk...@gmail.com


I have a generic type Pair<P,Q> that I want to extend a generic super class.
This seems to generate a checked_mode error when the super class has one type param.

class A<E>{}
class Pair<P,Q> extends A {
  final P fst;
  final Q snd;
  Pair(this.fst,this.snd);

}
main() {
  print(new Pair<int,int>(1,2));//OK no problems

  print(new Pair<String,int>("1",2));//checked-mode type err
}

krukow:~/scratchpad$ dart_bin --enable_type_checks generic.dart
Instance of 'Pair<int, int>'
Unhandled exception:
Failed type check: type Smi is not assignable to type String of snd in /Users/krukow/scratchpad/generic.dart at line 5, column 22.
 0. Function: 'Pair.Pair.' url: '/Users/krukow/scratchpad/generic.dart' line:5 col:22
 1. Function: '::.main' url: '/Users/krukow/scratchpad/generic.dart' line:12 col:9
 

where as if it has two:
class A<E,F>{}
we get:
krukow:~/scratchpad$ dart_bin --enable_type_checks generic.dart
Instance of 'Pair<int, int>'
Instance of 'Pair<String, int>'

Using dart_bin as of Dec. 6th.

Metadata

Metadata

Assignees

Labels

area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions