test/tools/javac/lambda/methodReference/MethodRef8.java

Thu, 26 Mar 2015 11:34:50 +0100

author
jlahoda
date
Thu, 26 Mar 2015 11:34:50 +0100
changeset 2734
ba758e1ffa69
parent 2611
9e80ab1dad9e
permissions
-rw-r--r--

8054220: Debugger doesn't show variables *outside* lambda
8058227: Debugger has no access to outer variables inside Lambda
Summary: Put local variables captured by lambda into the lambda method's LocalVariableTable.
Reviewed-by: mcimadamore, rfield

vromero@2611 1 /*
vromero@2611 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
vromero@2611 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
vromero@2611 4 *
vromero@2611 5 * This code is free software; you can redistribute it and/or modify it
vromero@2611 6 * under the terms of the GNU General Public License version 2 only, as
vromero@2611 7 * published by the Free Software Foundation.
vromero@2611 8 *
vromero@2611 9 * This code is distributed in the hope that it will be useful, but WITHOUT
vromero@2611 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
vromero@2611 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
vromero@2611 12 * version 2 for more details (a copy is included in the LICENSE file that
vromero@2611 13 * accompanied this code).
vromero@2611 14 *
vromero@2611 15 * You should have received a copy of the GNU General Public License version
vromero@2611 16 * 2 along with this work; if not, write to the Free Software Foundation,
vromero@2611 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
vromero@2611 18 *
vromero@2611 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
vromero@2611 20 * or visit www.oracle.com if you need additional information or have any
vromero@2611 21 * questions.
vromero@2611 22 */
vromero@2611 23
vromero@2611 24 /**
vromero@2611 25 * @test
vromero@2611 26 * @bug 8063052
vromero@2611 27 * @summary Inference chokes on wildcard derived from method reference
vromero@2611 28 * @compile MethodRef8.java
vromero@2611 29 */
vromero@2611 30
vromero@2611 31 public class MethodRef8 {
vromero@2611 32 void test(Box<? extends Box<? extends Number>> b) {
vromero@2611 33 Number n1 = b.map(Box::get).get();
vromero@2611 34 Number n2 = b.<Number>map(Box::get).get();
vromero@2611 35 }
vromero@2611 36
vromero@2611 37 interface Func<S,T> { T apply(S arg); }
vromero@2611 38
vromero@2611 39 interface Box<T> {
vromero@2611 40 T get();
vromero@2611 41 <R> Box<R> map(Func<T,R> f);
vromero@2611 42 }
vromero@2611 43 }

mercurial