mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8236850: Operations on constant List/Set.of(element) instances does not consistently constant fold
Reviewed-by: smarks, jrose, rriggs, psandoz
This commit is contained in:
parent
631b4d2694
commit
de96aeddf5
6 changed files with 219 additions and 100 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -789,7 +789,7 @@ public interface List<E> extends Collection<E> {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
static <E> List<E> of() {
|
||||
return (List<E>) ImmutableCollections.ListN.EMPTY_LIST;
|
||||
return (List<E>) ImmutableCollections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1033,7 +1033,7 @@ public interface List<E> extends Collection<E> {
|
|||
switch (elements.length) { // implicit null check of elements
|
||||
case 0:
|
||||
@SuppressWarnings("unchecked")
|
||||
var list = (List<E>) ImmutableCollections.ListN.EMPTY_LIST;
|
||||
var list = (List<E>) ImmutableCollections.EMPTY_LIST;
|
||||
return list;
|
||||
case 1:
|
||||
return new ImmutableCollections.List12<>(elements[0]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue