blob: 5ed7bf5caf86d82b694e53e140f247d144cfd55b [file] [log] [blame]
/*
* Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/
/**
* @assertion When invoked from a constant object expression, a constant constructor
* must throw an exception if any of its actual parameters is a value that would
* prevent one of the potentially constant expressions within it from being a valid
* compile-time constant.
* @description Checks that compile-time error is produced if actual parameters passed to the constructor
* make the constant initializer invalid. Note: this mechanism is described in Classes.Constructors.Constant_Constructors.
* @compile-error
* @author iefremov
* @reviewer rodionov
*/
class A {
final x;
const A(var p) : x = p + 42;
}
class IntPair {
const IntPair(this.x, this.y);
final int x;
final int y;
operator +(v) => new IntPair(x+v, y+v);
}
main() {
try {
var a = const A(const IntPair(1,2)); // parameter does not evaluate to int/bool/String, despite implementing the plus operator
} catch (x){}
}